﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using KZ.Exception;
using System.Data;

namespace KZ.Lottery.DAL
{
    public class GroupHighestDayDAL
    {
        public static DataTable GetGroupHighestDay(int status)
        {
            try
            {
                DataAccessHelper.SqlCmd.Parameters.Add("Status", SqlDbType.Int).Value = status;

                DataTable dt = new DataTable();
                dt.Load(DataAccessHelper.ExecuteQuery(CommandType.StoredProcedure, "procGroupHighestDayGetList"));

                return dt;
            }
            catch (SqlException ex)
            {
                Log.LogEx("GetGroupHighestDay", ex);
                throw;
            }
        }

        public static void InsertGroupHighestDay(string groupID, string ruleDetailID)
        {
            try
            {
                DataAccessHelper.SqlCmd.Parameters.Add("GroupID", SqlDbType.VarChar).Value = groupID;
                DataAccessHelper.SqlCmd.Parameters.Add("RuleDetailID", SqlDbType.VarChar).Value = ruleDetailID;

                DataAccessHelper.ExecuteNonQueryWithTransaction(CommandType.StoredProcedure, "procGroupHighestDayInsert");
            }
            catch (SqlException ex)
            {
                Log.LogEx("InsertGroupHighestDay", ex);
                throw;
            }
        }

        public static void UpdateGroupHighestDay(string groupID, string ruleDetailID)
        {
            try
            {
                DataAccessHelper.SqlCmd.Parameters.Add("GroupID", SqlDbType.VarChar).Value = groupID;
                DataAccessHelper.SqlCmd.Parameters.Add("RuleDetailID", SqlDbType.VarChar).Value = ruleDetailID;

                DataAccessHelper.ExecuteNonQueryWithTransaction(CommandType.StoredProcedure, "procGroupHighestDayUpdate");
            }
            catch (SqlException ex)
            {
                Log.LogEx("UpdateGroupHighestDay", ex);
                throw;
            }
        }
    }
}
